import {
    fileUpload,
    fileUploadOfText,
    initData,
    gvList,
    getResponseByFileUrl,
    fileUploadOfText2
} from "@/services/CommonService";

/**
 * 此处存放通用Model，多处调用的可以放在这里
 */

export default {
    namespace: 'commonModel',

    state: {},

    effects: {

        /**
         * 首页数据统计接口
         */
        * initData({payload, callback}, {call, put}) {
            const response = yield call(initData, payload);
            if (callback) callback(response);
        },
        /**
         * 文件上传 -> [电梯保险标志识别(formType=2),
         *             电梯设备使用标志识别(formType=1),
         *             营业执照识别(formType=4)]
         */
        * fileUpload({payload, callback}, {call, put}) {
            const response = yield call(fileUpload, payload);
            if (callback) callback(response);
        },

        /**
         * [文件上传] -> [普通图片上传和文件导入
         *              3:企业LOGO,
         *              7:保单PDF,
         *              8:帐户信息导入,
         *              9:报价表导入]
         */
        * fileUploadOfText({payload, callback}, {call, put}) {
            const response = yield call(fileUploadOfText, payload);
            if (callback) callback(response);
        },
        * gvList({payload, callback}, {call, put}) {
            const response = yield call(gvList, payload);
            if (callback) callback(response);
        },

        /**
         * [文件读取] -> [获取响应]
         * @Author 肖家添
         * @Date 2019/8/24 16:42
         */
        *getResponseByFileUrl({ payload, callback }, { call, put }) {
            const response = yield call(getResponseByFileUrl, payload);
            if (callback) callback(response);
        },

        /**
         * [文件上传] -> [文本上传]
         * @Author 肖家添
         * @Date 2019/8/24 10:42
         */
        *fileUploadOfText2({ payload, callback }, { call, put }) {
            const response = yield call(fileUploadOfText2, payload);
            if (callback) callback(response);
        },
    },

    reducers: {}
};
